package com.cium.aqie.objectOriented.extend

/**
 * @Function:
 * @Author: aqie
 * @Date: 2019/8/31 17:35
 */
fun main(args: Array<String>) {
    println("abc" * 16)
    println("abc".times(16))
    "abc".b = 6
    println("abc".b)
    println("abc".a)
}

/**
 *  运算符重载
 *  方法重载
 */
operator fun String.times(int: Int): String{
    val stringBuilder = StringBuilder()
    for(i in 0 until int){
        stringBuilder.append(this)
    }
    return stringBuilder.toString()
}

// 给String定义扩展成员 a
val String.a: String
    get() = "abc"

var String.b: Int
    set(value) {

    }
    get() = 5